﻿using System;
using System.Collections.Generic;
using MockDataTransferObject;
using System.Data.SqlClient;
using MockCommon;
using System.Data;
using System.Collections.ObjectModel;

namespace MockDataAccess
{
    public class ContractTypeDataAccess : BaseDataAccess<ContractType>
    {
        private Collection<SqlParameter> _parameters;
        
        /// <summary>
        /// Initializes a new instance of the <see cref="ContractTypeDataAccess"/> class.
        /// </summary>
        public ContractTypeDataAccess()
            : base()
        {
        }
        
        /// <summary>
        /// Initializes a new instance of the <see cref="ContractTypeDataAccess"/> class.
        /// </summary>
        /// <param name="isFake">if set to <c>true</c> [is fake].</param>
        public ContractTypeDataAccess(bool isFake)
            : base(isFake)
        {
        }

        #region Get
        /// <summary>
        /// Retrieves all contract types.
        /// </summary>
        /// <returns></returns>
        public DataTable RetrieveAllContractTypes()
        {
            DataTable table = ExecuteQueryAsDataTable(Constant.ContractTypeGetAll, null);
            return table;
        }

        /// <summary>
        /// Gets the name of the contract type id by contract type.
        /// </summary>
        /// <param name="contractTypeName">Name of the contract type.</param>
        /// <returns></returns>
        public object GetContractTypeIdByContractTypeName(string contractTypeName)
        {
            _parameters = new Collection<SqlParameter>();
            _parameters.Add(new SqlParameter { ParameterName = Constant.ParameterContractTypeName, Value = contractTypeName });
            return ExecuteQueryAsScalar(Constant.ContractTypeGetContractTypeIdByContractTypeName, _parameters);
        }
        #endregion
    }
}
